/* Floating Customer Service Icon */
.cs-floating-btn {
    position: fixed;
    bottom: 31vh;
    /* Aligned with 联系服务 button */
    right: 30px;
    width: 55px;
    height: 55px;
    background: #221e1d;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cs-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.cs-floating-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* Chat Modal Overlay */
.chat-modal-overlay {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: auto;
    height: auto;
    background: transparent;
    z-index: 30000;
    pointer-events: none;
}

/* Chat Modal Content */
.chat-modal-content {
    width: 505px;
    /* Reduced by 5% */
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
}

/* Chat Header */
.chat-header {
    background: #221e1d;
    color: #fff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.close-chat-modal {
    font-size: 24px;
    cursor: pointer;
    color: #fff;
    opacity: 0.8;
}

.close-chat-modal:hover {
    opacity: 1;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9f9f9;
}

.message {
    margin-bottom: 15px;
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.message p {
    margin: 0;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    display: inline-block;
    word-wrap: break-word;
    word-break: break-all;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    width: fit-content;
    max-width: 100%;
}

.system-message {
    align-self: flex-start;
    align-items: flex-start;
}

.system-message p {
    background: #fff;
    border: 1px solid #eee;
    color: #333;
    text-align: left;
}

.user-message {
    margin-left: auto;
    align-items: flex-end;
}

.user-message p {
    background: #221e1d;
    color: #fff;
    text-align: left;
}

/* Chat Input Area */
.chat-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

#chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
}

#chat-input:focus {
    border-color: #221e1d;
}

.send-btn {
    background: #221e1d;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #333;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 5px;
}

/* Attachment Button */
.icon-btn {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: #f0f0f0;
}

/* Rich Media Messages */
.message img,
.message video {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 5px;
    display: block;
    border: none;
}

.message .file-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 8px;
}

.message .file-icon {
    width: 30px;
    height: 30px;
    background: #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #555;
    font-weight: bold;
}

/* ==========================================================================
   手机端响应式样式 (max-width: 768px)
   ========================================================================== */

@media screen and (max-width: 768px) {

    /* 客服浮动按钮 - 缩小10%，向右移动更靠近边框 */
    .cs-floating-btn {
        width: 50px;
        /* 原55px缩小10%约等于50px */
        height: 50px;
        right: 15px;
        /* 更靠近右边框（原30px，减少到15px） */
        bottom: 25vh;
    }

    .cs-floating-btn svg {
        width: 25px;
        /* 同比缩小 */
        height: 25px;
    }

    /* 聊天窗口 - 手机端全屏模式 */
    .chat-modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        z-index: 99999;
        pointer-events: auto;
    }

    .chat-modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        /* 去掉圆角 */
        box-shadow: none;
        /* 去掉阴影 */
    }

    /* 聊天头部 - 缩小高度与底部输入栏一致 */
    .chat-header {
        padding: 10px 16px;
        /* 减小内边距使高度与底部一致 */
    }

    .chat-header h3 {
        font-size: 14px;
        /* 缩小标题字体 */
    }

    .close-chat-modal {
        font-size: 20px;
        /* 缩小关闭按钮 */
    }

    /* 聊天输入区域 - 适配全屏，水平排列 */
    .chat-input-area {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        /* 适配 iPhone 底部安全区域 */
    }

    #chat-input {
        flex: 1;
        font-size: 16px;
        /* 防止iOS自动缩放 */
        min-width: 0;
        /* 允许输入框收缩 */
    }

    .send-btn {
        flex-shrink: 0;
        /* 防止按钮收缩 */
        white-space: nowrap;
        /* 防止文字换行 */
        padding: 10px 16px;
        font-size: 14px;
    }

    .icon-btn {
        flex-shrink: 0;
        /* 附件按钮也不收缩 */
    }
}